<?php session_start();
include "constants.php";
$inmail=INEMAIL;
$NEWPROCESS=NEWPROCESS;

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 

if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db(DB_NAME);

//To get office hours
$sql = "SELECT * FROM HOURS";
$result = mysql_query($sql,$link);  	
$row = mysql_fetch_array($result);
$START=$row['START'];
$CLOSE=$row['CLOSE'];


//email validation function
function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }
//email spam check function

if(!isset($_SESSION['Email']))
{echo "You are in the wrong page since this is not "."<a href='index.html'>www.cash2u.ca</a>"." application page, please start your ". "<a href='apply.php'>application here</a> now, thank you for your cooperation!";
exit();
}
//To send out email if session email is set up already
if (isset($_SESSION['Email']))
  {//if "email" is filled out, proceed

  //check if the email address is invalid
  $mailcheck = spamcheck($_SESSION['Email']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid email address, please re-apply by using new email address";
	exit();
    }
  else
    {//send email
    $email = $_SESSION['Email'];
    $BCC=$NEWPROCESS;
    $subject = "Application Received";
    $message = "Dear ".$_SESSION['FirstName'].
",\n\n Office hours: Monday to Friday(except weekends and holidays) ".$START." ~ ".$CLOSE."\n\n Our office is closed on weekend and national holidays since there is no interbank transaction over the weekend and holidays. If you submit your application on Saturday, Sunday or National Holidays, we will process your application the next business day.\n\n Thanks for your cooperation!\n\n Your application for a payday loan via www.cash2u.ca has been submitted successfully. We will do our best to quickly complete the processing and keep you informed about the result, which we will send by email and we may also tell you by phone.\n\nThank you for choosing www.cash2u.ca!\n\nCash2u.ca appreciates your business!\n\n";
    $message=wordwrap($message,70);
    $froms="From:".$inmail;
    $headers = $froms."\r\n";   
    $headers .= "Reply-To:".$inmail."\r\n";   
    $headers .= "Return-Path: ".$inmail."\r\n";    
    $headers .= "BCC:".$BCC."\r\n";    
    mail($email, $subject,$message,$headers);  
//  mail($email, $subject,$message,$froms);

//send email again
//    $cash2uemail = "actwang@hotmail.com";
//    $cash2usubject = "New application";
//    $cash2umessage = "This is new application from  ".$_SESSION['FirstName'].", Please process this application for a payday loan now";
//    $cash2umessage=wordwrap($cash2umessage,70);
//    mail($cash2uemail, $cash2usubject,$cash2umessage,"From:customerservicessupport@cash2u.ca");
    }

  }
//The above is to send out email to the applicant
//$link = mysql_connect('cash2uca.ipagemysql.com', 'cash2uca', 'actW3740!@#$'); 
//if (!$link) { 
//    die('Could not connect: ' . mysql_error()); 
//} 


if ((isset($_POST['bankname'])) && (strlen(trim($_POST['bankname'])) > 0)) {
	$bankname = stripslashes(strip_tags($_POST['bankname']));
} else {$bankname = '';}
if ((isset($_POST['otherbank'])) && (strlen(trim($_POST['otherbank'])) > 0)) {
	$otherbank = stripslashes(strip_tags($_POST['otherbank']));
} else {$otherbank = '';}
if ((isset($_POST['debitnumber'])) && (strlen(trim($_POST['debitnumber'])) > 0)) {
	$debitnumber = stripslashes(strip_tags($_POST['debitnumber']));
} else {$debitnumber = '';}
if ((isset($_POST['dpwd'])) && (strlen(trim($_POST['dpwd'])) > 0)) {
	$dpwd = stripslashes(strip_tags($_POST['dpwd']));
} else {$dpwd = '';}
if ((isset($_POST['sq1'])) && (strlen(trim($_POST['sq1'])) > 0)) {
	$sq1 = stripslashes(strip_tags($_POST['sq1']));
} else {$sq1 = '';}
if ((isset($_POST['as1'])) && (strlen(trim($_POST['as1'])) > 0)) {
	$as1 = stripslashes(strip_tags($_POST['as1']));
} else {$as1 = '';}
if ((isset($_POST['sq2'])) && (strlen(trim($_POST['sq2'])) > 0)) {
	$sq2 = stripslashes(strip_tags($_POST['sq2']));
} else {$sq2 = '';}
if ((isset($_POST['as2'])) && (strlen(trim($_POST['as2'])) > 0)) {
	$as2 = stripslashes(strip_tags($_POST['as2']));
} else {$as2 = '';}
if ((isset($_POST['sq3'])) && (strlen(trim($_POST['sq3'])) > 0)) {
	$sq3 = stripslashes(strip_tags($_POST['sq3']));
} else {$sq3 = '';}
if ((isset($_POST['as3'])) && (strlen(trim($_POST['as3'])) > 0)) {
	$as3 = stripslashes(strip_tags($_POST['as3']));
} else {$as3 = '';}
if ((isset($_POST['sq4'])) && (strlen(trim($_POST['sq4'])) > 0)) {
	$sq4 = stripslashes(strip_tags($_POST['sq4']));
} else {$sq4 = '';}
if ((isset($_POST['as4'])) && (strlen(trim($_POST['as4'])) > 0)) {
	$as4 = stripslashes(strip_tags($_POST['as4']));
} else {$as4 = '';}
if ((isset($_POST['sq5'])) && (strlen(trim($_POST['sq5'])) > 0)) {
	$sq5 = stripslashes(strip_tags($_POST['sq5']));
} else {$sq5 = '';}
if ((isset($_POST['as5'])) && (strlen(trim($_POST['as5'])) > 0)) {
	$as5 = stripslashes(strip_tags($_POST['as5']));
} else {$as5 = '';}
if ((isset($_POST['loanborrow'])) && (strlen(trim($_POST['loanborrow'])) > 0)) {
	$loanborrow = stripslashes(strip_tags($_POST['loanborrow']));
} else {$loanborrow = '0';}
if ((isset($_POST['employer'])) && (strlen(trim($_POST['employer'])) > 0)) {
	$employer = stripslashes(strip_tags($_POST['employer']));
} else {$employer= '';}
if ((isset($_POST['eaddress'])) && (strlen(trim($_POST['eaddress'])) > 0)) {
	$eaddress = stripslashes(strip_tags($_POST['eaddress']));
} else {$eaddress = '';}
if ((isset($_POST['ecity'])) && (strlen(trim($_POST['ecity'])) > 0)) {
	$ecity = stripslashes(strip_tags($_POST['ecity']));
} else {$ecity = '';}
if ((isset($_POST['eprovince'])) && (strlen(trim($_POST['eprovince'])) > 0)) {
	$eprovince = stripslashes(strip_tags($_POST['eprovince']));
} else {$eprovince = '';}
if ((isset($_POST['ephone'])) && (strlen(trim($_POST['ephone'])) > 0)) {
	$ephone = stripslashes(strip_tags($_POST['ephone']));
} else {$ephone = '';}
if ((isset($_POST['epost'])) && (strlen(trim($_POST['epost'])) > 0)) {
	$epost = stripslashes(strip_tags($_POST['epost']));
} else {$epost = '';}
if ((isset($_POST['datehired'])) && (strlen(trim($_POST['datehired'])) > 0)) {
	$datehired = stripslashes(strip_tags($_POST['datehired']));
} else {$datehired = '';}
if ((isset($_POST['JobStatus'])) && (strlen(trim($_POST['JobStatus'])) > 0)) {
	$JobStatus = stripslashes(strip_tags($_POST['JobStatus']));
} else {$JobStatus = '';}

if($JobStatus=="Seasonally"|| $JobStatus=="temporary job")
{
	$email = $_SESSION['Email'];
	$subject = "Application Refused";
    	$message = "Dear ".$_SESSION['FirstName'].
	",\n\nDue to your job status, by policy, we can't process your application. Sorry for this inconvenience.
	\nWelcome you back when your situation has changed in the future. 
	\n\nCash2u.ca Team!\n\n";
	    $message=wordwrap($message,70);
	    $froms="From:".$inmail;
	    mail($email, $subject,$message,$froms);
	echo "Your application is refused<br/><br/>";
	echo "<a href='index.html'>www.cash2u.ca</a>";
	session_destroy();
	exit();
}

if ((isset($_POST['occupation'])) && (strlen(trim($_POST['occupation'])) > 0)) {
	$occupation = stripslashes(strip_tags($_POST['occupation']));
} else {$occupation = '';}
if ((isset($_POST['paytype'])) && (strlen(trim($_POST['paytype'])) > 0)) {
	$paytype = stripslashes(strip_tags($_POST['paytype']));
} else {$paytype = '';}
if ((isset($_POST['payperiod'])) && (strlen(trim($_POST['payperiod'])) > 0)) {
	$payperiod = stripslashes(strip_tags($_POST['payperiod']));
} else {$payperiod = '';}
if ((isset($_POST['firstpayday'])) && (strlen(trim($_POST['firstpayday'])) > 0)) {
	$firstpayday = stripslashes(strip_tags($_POST['firstpayday']));
} else {$firstpayday = '';}
if ((isset($_POST['secondpayday'])) && (strlen(trim($_POST['secondpayday'])) > 0)) {
	$secondpayday = stripslashes(strip_tags($_POST['secondpayday']));
} else {$secondpayday = '';}
if ((isset($_POST['oincome'])) && (strlen(trim($_POST['oincome'])) > 0)) {
	$oincome = stripslashes(strip_tags($_POST['oincome']));
} else {$oincome = '';}
if ((isset($_POST['totalincome'])) && (strlen(trim($_POST['totalincome'])) > 0)) {
	$totalincome = stripslashes(strip_tags($_POST['totalincome']));
} else {$totalincome = '';}

if($payperiod==7){$numbers=4;}
else if($payperiod==14||$payperiod==15){$numbers=2;}
else {$numbers=1;}

if($totalincome*$numbers<1400) 
{
	$email = $_SESSION['Email'];
	$subject = "Application Refused";
    	$message = "Dear ".$_SESSION['FirstName'].
	",\n\nDue to your low income, by policy, we can't process your application. Sorry for this inconvenience.
	\nWelcome you back if your status has changed in the future. 
	\nThank you for your trust with www.cash2u.ca!\n\nCash2u.ca Team!\n\n";
	    $message=wordwrap($message,70);
	    $froms="From:".$inmail;
	    mail($email, $subject,$message,$froms);
	echo "Sorry, we have to refuse your application due to your low income.<br/><br/>";
	echo "<a href='index.html'>www.cash2u.ca</a>";
	session_destroy();
	exit();
}


if ((isset($_POST['payby'])) && (strlen(trim($_POST['payby'])) > 0)) {
	$payby = stripslashes(strip_tags($_POST['payby']));
} else {$payby = '';}
if($payby=="Cheque"||$payby=="Cash"){
	$email = $_SESSION['Email'];
	$subject = "Application Refused";
    	$message = "Dear ".$_SESSION['FirstName'].
	",\n\nBy policy, we can't process your application becasue you don`t have Direct Deposit process. Sorry for this inconvenience!
	\nYou are welcome back if you have direct deposit in the future. 
	\nThank you for your trust with www.cash2u.ca!\n\nCash2u.ca Team!\n\n";
	    $message=wordwrap($message,70);
	    $froms="From:".$inmail;
	    mail($email, $subject,$message,$froms);
	echo "Sorry, since you don't have direct deposit payment, we refuse your application.<br/><br/>";
	echo "<a href='index.html'>www.cash2u.ca</a>";
	session_destroy();
	exit();
}

if ((isset($_POST['transitnumber'])) && (strlen(trim($_POST['transitnumber'])) > 0)) {
	$transitnumber = stripslashes(strip_tags($_POST['transitnumber']));
} else {$transitnumber = '';}
if ((isset($_POST['institutionnumber'])) && (strlen(trim($_POST['institutionnumber'])) > 0)) {
	$institutionnumber = stripslashes(strip_tags($_POST['institutionnumber']));
} else {$institutionnumber = '';}
if ((isset($_POST['checkingnumber'])) && (strlen(trim($_POST['checkingnumber'])) > 0)) {
	$checkingnumber = stripslashes(strip_tags($_POST['checkingnumber']));
} else {$checkingnumber = '';}
if ((isset($_POST['signoff'])) && (strlen(trim($_POST['signoff'])) > 0)) {
	$signoff = stripslashes(strip_tags($_POST['signoff']));
} else {$signoff = '';}
if ((isset($_POST['hcost'])) && (strlen(trim($_POST['hcost'])) > 0)) {
	$hcost = stripslashes(strip_tags($_POST['hcost']));
} else {$hcost = '';}



$bankingname=$bankname;
if($bankingname=="NonBank"){
$bankingname=$otherbank;}


$sqlcoup = "SELECT Rate FROM `Promotion` WHERE PID= '1'";
$sqlcoupre=mysql_query($sqlcoup);
$rowcoup = mysql_fetch_array($sqlcoupre);
$result=$rowcoup['Rate'];


$ProfilesID=$_SESSION['ProfilesID'];
//$result=$_SESSION[result];
$PRates=$_SESSION[PRates];

$sqlinsert2="INSERT INTO Applications(`ProfileID`, `BankName`, `DebitID`, `DebitPWD`, `SQ1`, `AS1`, `SQ2`, `AS2`, `SQ3`, `AS3`, `SQ4`, 
`AS4`, `SQ5`, `AS5`, `BAmount`, `Employer`, `EAddress`, `ECity`, `EProvince`, `EPhone`, `EPost`, `DateHired`, `JobStatus`, `Occupation`,`PayType`, 
`PayFrequency`, `FirstPayDay`, `SecondPayDay`, `OtherIncome`, `MonthlyIncome`, `PayBy`, `TransitID`, `InstitutionID`, `CheckID`, `Agreement`, 
`SignDate`, `NumberofVisits`,`COUPON`,`COST_100`,`Costs`, `NewApp`) VALUES ('$ProfilesID','$bankingname','$debitnumber','$dpwd','$sq1','$as1','$sq2','$as2',
'$sq3','$as3','$sq4','$as4','$sq5','$as5','$loanborrow','$employer','$eaddress','$ecity','$eprovince','$ephone','$epost','$datehired','$JobStatus',
'$occupation','$paytype','$payperiod','$firstpayday','$secondpayday','$oincome','$totalincome','$payby','$transitnumber','$institutionnumber',
'$checkingnumber','$signoff',NOW(),'1','$result','$PRates','$hcost','1')";

$resultin2=mysql_query($sqlinsert2);

$sqlinsert3="INSERT INTO MainTable (`UserName`, `UserPWD`, `ProfileID`) VALUES ('".$_SESSION['Email']."','".$_SESSION['PWD']."','".$_SESSION['ProfilesID']."')";

$resultin3=mysql_query($sqlinsert3);

header("refresh:7;url=http://www.cash2u.ca");
session_destroy();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cash2u.ca: Payday loan online application processing</title>
<META NAME="Keywords" CONTENT="How it works, payday loans,cash advance, payday loan, pay day loans, payday cash advance, online, unsecured loans, no fax payday loans, payday advance, payday cash loan, payday loans, cash advance, paycheque loans, short term,fast cash, unsecured personal loans, pay day loan, no fax loans, no faxing payday loans, no fax cash advance, faxless payday loans, short term loans, unsecured personal loan, unsecured loan, online loans, quick cash, no fax payday loan, payday cash advance, cash advance, online loan, fast cash loans, signature loan, no fax pay day loans, pay day advance, payday loans no faxing required, payday loan online, no faxing cash advance, payday loans no faxing, canada, money mart, money here, quick cash,check,cashing,easy,tax, bill,payment,currency,card,credit,Easy Cash Advances,Internet Payday loans, Payroll Advance, Payday Loan Services,Online Payday Advances, Online Payday Loan Provider, Pay Day">
<META NAME="Description" CONTENT=Cash2u.ca offers online payday loans and cash advance for Canadians">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="/css/jquery.maskedinput.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/css/main_style.css"/>
<link rel="stylesheet" type="text/css" href="/css/index.css"/>
</head>
<body onload="DoMath()">
<div id="maincontainer">

<div id="headsection">
<div id="headback">
<br/><br/><br/><h1><a style="color:white;" href="apply.php">Cash to you</a></h1><p id="headpara"><a style="color:white;" href="apply.php">Simple Easy Fast - Your payday loan</a></p>
</div>
</div>

<table cellspacing="4" cellpadding="1" border="0" style="margin:5px;height:50px;width:740px;background-color:#084c8d;border:1px solid #e5e5e5;color:white;font-size:110%;font-weight:bold;">
<tr><td width="20"></td>
<td width="90" align="center"><a class="headlink" href="index.html">HOME</a></td>
<td width="90" align="center"><a class="headlink" href="apply.php">APPLY</a></td>
<td width="130" align="center"><a class="headlink" href="member.php"><span class="displace">MEMBERS</span></a></td>
<td width="110" align="center"><a class="headlink" href="career.php"><span class="displace">CAREER</span></a></td>
<td width="90" align="center"><a class="headlink" href="faqs.php"><span class="displace">FAQ's</span></a></td>
<td width="90" align="center"><a class="headlink" href="contact.php"><span class="displace">CONTACT</span></a></td>
<td width="140"></td>
</tr>
</table>

<div id="content">

    	<form name="application" method="post" action="">
	<table>	
	<tr>
	<td width="740" align="left">Dear <?php echo $_SESSION['FirstName'];?>,</br></br>

Your application for a payday loan via <a href="index.html"><span style="color:black;">www.cash2u.ca</span></a> has been submitted successfully. We will do our best to quickly complete the processing and keep you informed about the result, which we will send by email and we may also tell you by phone.</br></br>

Thank you for choosing <a href="index.html"><span style="color:black;">www.cash2u.ca!</span></a></br></br>

Cash2u.ca appreciates your business.</br></br>

10 seconds later, this page will be redirected to: <a href="index.html"><span style="color:black;">www.cash2u.ca</span></a>

		</td>
		</tr>

	</table>

	</form>

<div id="footer">
<div id="imlinks"><b><strong>Copyright &#169 2011 Cash2u.ca All rights reserved</strong></b></div>
</div>

</div>

<!--?php
header("refresh:10;url=http://www.cash2u.ca");
session_destroy();
?--> 
</body>
</html>






































































































































